<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiConfigTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_config';

    /**
     * Run the migrations.
     * @table qii_config
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('配置ID');
            $table->string('name', 30)->default('')->comment('配置名称');
            $table->unsignedTinyInteger('type')->default('0')->comment('配置类型');
            $table->string('title', 50)->default('')->comment('配置说明');
            $table->unsignedTinyInteger('group')->default('0')->comment('配置分组');
            $table->string('extra')->default('')->comment('配置值');
            $table->string('remark', 100)->comment('配置说明');
            $table->unsignedInteger('create_time')->default('0')->comment('创建时间');
            $table->unsignedInteger('update_time')->default('0')->comment('更新时间');
            $table->tinyInteger('status')->default('0')->comment('状态');
            $table->text('value')->comment('配置值');
            $table->unsignedSmallInteger('sort')->default('0')->comment('排序');
            $table->unsignedSmallInteger('is_wap')->default('0')->comment('移动端配置');

            $table->index(["group"], 'group');

            $table->index(["type"], 'type');

            $table->unique(["name"], 'uk_name');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
